home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EuroCD 3
/
EuroCD 3.iso
/
Miscellaneous
/
StopWatch
/
StopWatch.doc
< prev
next >
Wrap
Text File
|
1998-06-24
|
29KB
|
583 lines
S t o p W a t c h
Version 3.0
December 06, 1991
by
Christian Danner
M A N U A L
===========
PRINCIPLES
"StopWatch" is a stop watch application, which makes a programmable precision
of more than the by the system time offered 1/50 second possible (with a
standard Amiga 500/1000/2000 e.g. a resolution of one millisecond occupies only
little processor time, with a turbo board this value can furthermore be
increased).
The program reacts on the status of the joystick button. It gets its timebase
from the CIA B timer A and in the last resort from the 7.16 MHz system
frequency by interrupt programming. After many - by reason of inaccuracy -
frustrating experiments with the CIA A timer A, which ought to be the only one
available for free access according to the Addison Wesley Hardware Manual and
other publications, I used this pretendedly by EXEC continuously occupied
timer. Till now no incompatibilities occurred. The interrupt priority level 6
prevents the timer program from being overrun by other interrupts and
guarantees a high degree of precision.
I tested the program on different conditions. During car races I'm using it in
the background, where the input data come from a hardware interface producing a
short circuit to the according joystick port wires when the time measurement
beam of a light barrier is interrupted. At the same time a Superbase
application is running on this machine, communicating with another Amiga via
the serial device for displaying the score lists and serving a printer
connected to the parallel port. In comparison with a professional stop watch
running simultaneously, I couldn't find out any difference in the resulting
times. Corresponding to my tests, normal Intuition interfacing, file handling
etc. might not corrupt the timer. So far I only found one program, a sound
generator, which caused deviations.
FEATURES
The program displays the single lap times and the total times in a window on
the Workbench screen. You can determine the number of laps per race and the
period of time, within which no incoming signal is processed after a valid
event. In an uncomplicated manner you can adjust the measurement on your
equipment (I have not yet tested, whether it's necessary or not, but it might
be required depending on the quartz base). Optionally for the purpose of
transmitting the results to other applications, the data can be saved to a disk
file in ASCII-format. You can specify the filename freely, a selection between
only saving total times or saving all lap-times is possible, just as you can
choose whether the file only has to contain the last time or a time list shall
be generated. Also an ARexx-port for remote control with parameter modification
and a more comfortable result handling is implemented. With Version 3.0 an
additional screen can be opened as a time display e.g. in combination with a
genlock interface. Text and primitive graphics can also be written to this
screen via Rexx-commands.
HARDWARE
As I explained earlier, the program scans the status of the joystick button,
which is a simple switch connecting Pin 6 with Pin 8 of the joystick plug when
it is closed. Pressing the button is a valid event for the timer. You can
trigger the timer manually or by an interface, which "presses the button" for
you by a switch (mechanic or optoelectronic), e.g. controlled by a light
barrier.
If the signal to detect is active only for a period of time shorter than the
interval between two scans of the input it might be ignored by the timer.
Therefore you have to delay the release of the switch (with an electronic
circuit) for a reliable measurement of such signals.
CALIBRATION
First you have to select the resolution of the timer, which means the
frequency of timer increase (e.g. 1000 for a resolution of 1/1000 second). This
value should not be excessively high, because you can slow down the system
rapidly by the timer interrupts.
Now you have to tune the timer by changing the VIACYCL-Values
("VIA-Cycles/Timercycle" in the Workbench window), so that the resulting times
are mostly valid in comparison with an already calibrated stopwatch. Doing
this, the "Correction-factor" has to be 0.
For a fine adjustment a correction factor can be defined, which is equivalent
to the time deviation divided by the total period of time where it occurred. To
be able to supervise this adjustment, the resulting correction value is
displayed in terms of milliseconds with every measurement in the last of the
three columns.
PARAMETERS
All the parameters can be transmitted to the program when starting it. I have
implemented certain commands for the startup from the CLI, ToolTypes for
running "StopWatch" from the WorkBench and Rexx-commands to influence the
already started application.
ToolType CLI PrgWindow Explanation
---------------------------------------------------------------------------
General:
--------
LAPS=number -l.. Number of Laps number of laps per race
REFRACT=number -r.. Refract.-Time refractory time after a pass
CYCLSEC=number -s.. Resolution number of timercycles per second
VIACYCL=number -v.. VIA-Cycles / Ti. coarse tuning of the timer
CORRECT= number -c.. Correctionfactor timer fine tuning factor [* 1E-6]
DISPLAY=number -d.. not implemented number of result lines in display
BEEP=ON -b not implemented display beep after timer events
FILE=path/filename -f.. not implemented filename for saving the results
APPEND=ON -a not implemented generate result-list
PASS=ON -p not implemented save also lap-times
Display Screen:
---------------
SCREEN=number -o.. not implemented display screen depth
WIDTH=number -w.. not implemented width
HEIGHT=number -h.. not implemented height
COLORS=hexnumbers -k.. not implemented colors
ACTTIDIG=number -(.. not implemented actual time digits after the
decimal point
TOTTIDIG=number -).. not implemented total / lap time digits after the
decimal point
TIFGCOLOR=number -e.. not implemented time display color of characters
TIBGCOLOR=number -g.. not implemented background
TIMEFNAME=fontname -n.. not implemented time font name (disk font !)
TIMEFSIZE=number -z.. not implemented size
TEXTFNAME=fontname -m.. not implemented text font name (disk font !)
TEXTFSIZE=number -q.. not implemented size
TOTLEFT=number -t.. not implemented coordinate time total left
TOTUP=number -u.. not implemented up
LAPLEFT=number -i.. not implemented lap left
LAPUP=number -j.. not implemented up
ACTLEFT=number -x.. not implemented actual left
ACTUP=number -y.. not implemented up
Parameter Valid data range Preset
---------------------------------------------------------------------------
LAPS 1 .. 99999 1
REFRACT 1 .. 99999 500
CYCLSEC 1 .. 50000 1000
CORRECT -9999 .. 99999 -525
VIACYCL 50 .. 50000 708
DISPLAY 2 .. 12 5
BEEP OFF .. ON OFF
APPEND OFF .. ON OFF
PASS OFF .. ON OFF
SCREEN 1 .. 4 no display screen
WIDTH 640 .. 767 640
HEIGHT 400 .. 766 400
COLORS 66AFFF000D000D000BDD0D0B0DB
ACTTIDIG 0 .. 1 1
TOTTIDIG 0 .. 3 3
TIFGCOLOR 0 .. number of colors - 1 (1/3/7/15) 1
TIBGCOLOR 0 .. number of colors - 1 (1/3/7/15) 0
~LEFT 0 .. WIDTH - TextWidth( "00:00:00.000") 150
~UP 0 .. HEIGHT - TextHeight
ACTUP 150
LAPUP 180
TOTUP 210
Time-/Text-Font no font selected
Examples:
---------
~FNAME RUBY (extension ".font" not allowed)
~FSIZE 15
COLORS 00AFFF000C00444DD00D000A...
\_/
rgb color 0 = blue (hexadecimal Red/Green/Blue-values 0..F)
\_/
rgb color 1 = white
\_/
rgb color 2 = black
\_/
rgb color 3 = red
...
Command line for CLI-Startup:
StopWatch -l2 -r500 -s1000 -v708 -c-525 -d5 -b -fCLIPS:TimeList -p -a
-o3 -w704 -h460 -k44afff000c00 -x495 -y350 -i250 -j350 -t495
-u350 -nstopwatch -z26 -e1 -g2
To modify the parameters in the Workbench window you first have to click on the
"STATE"-button or to select the pulldown menu "Project/Parameters". Then a
modification of the values in the parameter field is possible. When done click
on the same button again. This sets the new values and zeroes the timer. A
reset also can be processed simply by selecting the according pulldown menu.
The state of the system is displayed in an area above the "STATE"-Button. For
preventing the timer from analyzing uninteresting signals a locking function
can be activated by pressing the "LOCK"-button or sending the corresponding
Rexx command. You return to the normal timer action by pressing the button
again or using the Rexx command "UNLOCK".
Notes: Even if the continuous time display skips some values and runs
irregular (not enough system preformance for the defined timer
settings) the resulting times are valid! Time measurement and time
display are different, parallel running processes.
A VIACYCL-value < 150 may freeze a system without accelerator card by
occupancy of a great amount of calculating time for handling the timer
interrupts! You could check this with a performance monitor. If you
intend to use this program only as a Rexx-controlled display unit set
VIACYCL to its maximum value (10000) for the least possible loss of
system preformance.
To protect the timer from being triggered repeatedly by an instable
signal when the joystick button is pressed or released, it is possible
to define a period of time, during which no check of the input signal
is performed after an event. E.g. in car races with longer refractory
times this feature can also be useful to prevent the timer started by
the front wheels from being stopped by the rear wheels.
The strategy: 1. After a valid event (button pressed = signal on =
pins connected) the input is scanned for the release
of the button.
2. At that moment the refractory time, which determines
the period, during which a signal is ignored by the
timer, is set to the user-defined REFRACT-value and
counted down.
3. If there is another event within this time, the
program ignores it and repeats the whole procedure
beginning at 1 (scanning for the release of the
button...).
This loop is performed until no event occurs during
the time of delay.
4. Subsequently the timer is active for the next event.
The power led indicates the state of this feature. If it shines
brighter, the input is inactive. For a premature activation with a
running timer you have to lock / unlock the input. A reset also
activates the input, but the actually measured time is lost.
The format of the actual and total / lap time displayed in the
separate screen is shortened depending on the defined TIMEDIGITS
values: 3 "00:00:00.000"
2 "00:00:00.00"
1 "00:00:00.0"
0 "00:00:00"
The time strings transmitted to the stopwatch window, the output file
and Rexx are never truncated to make the further processing easier.
When using proportional fonts for time display all digits and the
characters " ", "." and ":" must have the same width for correct
output and deletion. If necessary modify the respective font with a
font-editor.
The display screen depth determines the maximum number of screen
colors. Depth 1/2/3/4 means 2/4/8/16 colors (colors = depth^2). The
time needed for text- and graphics output increases with the screen
depth, so avoid unused bitplanes! Toggle between the "StopWatch"- and
the Workbench screen with the keys <Amiga>-N and <Amiga>-M.
Caution: On my Amiga 2000B PAL with Agnus 8361 / Denise 8362 some baselines
(below line 455) are not shown on a screen with the depth of
4 bitplanes, but they are present and can be dumped to the printer by
the use of a screen grabber. Maybe this fault does no longer appear
in combination with the ECS-Chipset and 1 MB chip memory, but I was
not yet able to check this hardware.
REXX-COMMANDS
The ARexx-port of "StopWatch" can be accessed via its name "RexxStopWatch".
So far the following commands are implemented:
General:
--------
CLOSE ends the program
parameters: none
LOCKEXIT forbids ending of the program (except via REXX)
parameters: none
returncode: warn: LOCKEXIT already active
UNLOCKEXIT resets the LOCKEXIT-command
parameters: none
returncode: warn: LOCKEXIT not active
RESET resets the timer
parameters: none
LOCKTIMER disconnects the timer from the joystick port
parameters: none
UNLOCKTIMER resets the LOCKTIMER-command
parameters: none
LAPS number of laps per race
parameters: <number>
returncode: error: no parameter
parameter out of range
REFRACT refractory (delay) time after a pass
parameters: <number>
returncode: see "LAPS"
CYCLSEC number of timercycles per second
parameters: <number>
returncode: see "LAPS"
VIACYCL coarse tuning of the timer
parameters: <number>
returncode: see "LAPS"
CORRECT timer fine tuning factor [* 1E-6]
parameters: < number>
returncode: see "LAPS"
BEEP display beep after timer events
parameters: [ON]/[OFF]
returncode: error: no / wrong parameter
NEXTTOTAL returns the next total time
parameters: none
format of result: "00:00:00.000"
(depending on "CYCLSEC" filled with "0")
returncode: warn: timer overflow (> "99:59:59.999")
error: rexx result handling disabled
(no "OPTIONS RESULTS" command)
NEXTLAP returns the next additive lap time
parameters: none
format of result: see "NEXTTOTAL"
returncode: see "NEXTTOTAL"
NEXTSINGLE returns the next single lap time
parameters: none
format of result: see "NEXTTOTAL"
returncode: see "NEXTTOTAL"
PREVTOTAL returns the previous total time
parameters: none
format of result: see "NEXTTOTAL"
returncode: see "NEXTTOTAL"
PREVLAP returns the previous additive lap time
parameters: none
format of result: see "NEXTTOTAL"
returncode: see "NEXTTOTAL"
PREVSINGLE returns the previous single lap time
parameters: none
format of result: see "NEXTTOTAL"
returncode: see "NEXTTOTAL"
Display Screen:
---------------
SCREENADDRESS returns the pointer to the display screen structure for external
screen manipulations (before using this feature you should call
the LOCKEXIT-command to avoid a closure of the screen from the
workbench, which might cause a system crash)
parameters: none
result: <address in decimal text format>
returncode: warn: timer overflow
error: rexx result handling disabled
(no "OPTIONS RESULTS" command)
TIMEDIGITS changes the number of digits following the decimal point when
the actual and total (lap) time is displayed
parameters: <digits actual time> <digits total / lap time>
returncode: see "LAPS"
TIMEPOS changes position of actual, total and lap time
parameters: <xact> <yact> <xtot> <ytot> <xlap> <ylap>
returncode: error: position(s) out of screen range
-> no change
warn: text too large for correct display
-> position(s) shifted
TIMECOLOR defines foreground- and background color of time display font
parameters: <foreground color> <background color>
returncode: error: no / wrong parameters
TIMEFONT changes the time display font. It also clears the locations of
the actual, lap and total time!
parameters: <name> <size>
returncode: error: no / wrong parameters
diskfont not available
TEXTFONT changes the text display font used by the ~TEXT~-commands
parameters: <name> <size>
returncode: see "TIMEFONT"
BOXO draws an opaque filled box
parameters: <left> <up> <width> <height> <color>
returncode: error: no / wrong parameters
parameters out of range
(object has to fit into the screen)
BOXT draws a transparent filled box (by alternation of pixels in
foreground- and background color)
parameters: <left> <up> <width> <height> <color>
returncode: see "BOXO"
DRAW draws a dot, line or polygon
parameters: for dot <color> <x-pos.> <y-pos.>
for line <color> <x1> <y1> <x2> <y2>
for polygon <color> <x1> <y1> <x2> <y2> <x3> ..
returncode: see "BOXO"
FILL fills an area with a plain color beginning at the specified
position, delimited by the determined outline color
parameters: <x-pos.> <y-pos.> <color>
returncode: see "BOXO"
ELLIPSE draws an opaque filled ellipse
parameters: <center x> <ct. y> <radius x> <rd. y> <color>
returncode: see "BOXO"
LOGO displays copyright logo
parameters: <left> <up>
returncode: see "BOXO"
CLRLOGO clears copyright logo
parameters: <left> <up>
returncode: see "BOXO"
TEXTR text output from the defined position to the right
parameters: <left> <up> <textcolor> <backgroundcolor> <text>
returncode: see "BOXO"
if necessary text is shortened without error
message !
TEXTL text output from the defined position to the left
parameters: <left> <up> <textcolor> <backgroundcolor> <text>
returncode: see "TEXTR"
TEXTC text output centered horizontal relative to the position
parameters: <left> <up> <textcolor> <backgroundcolor> <text>
returncode: see "TEXTR"
CLRTEXTR clears text written with TEXTR
parameters: <left> <up> <text>
returncode: see "TEXTR"
CLRTEXTL clears text written with TEXTL
parameters: <left> <up> <text>
returncode: see "TEXTR"
CLRTEXTC clears text written with TEXTC
parameters: <left> <up> <text>
returncode: see "TEXTR"
SHADOW sets shadowtext coordinates
(in pixels relative to normal text position = 0 / 0)
parameters: <x-pos shadow 1> <y-pos shadow 1> <x2> <y2> ..
preset: "-1 -1 0 -1 1 -1 -1 0 1 0 -1 1 0 1 1 1"
restriction: max. 30 shadows (60 x/y-values) allowed
returncode: see "BOXO"
TEXTRS text output to the right with shadows
parameters: <left> <up> <textcolor> <shadowcolor> <text>
returncode: see "TEXTR"
TEXTLS text output to the left with shadows
parameters: <left> <up> <textcolor> <shadowcolor> <text>
returncode: see "TEXTR"
TEXTCS text output centered horizontal with shadows
parameters: <left> <up> <textcolor> <shadowcolor> <text>
returncode: see "TEXTR"
CLRTEXTRS clears text written with TEXTRS
parameters: <left> <up> <text>
returncode: see "TEXTR"
CLRTEXTLS clears text written with TEXTLS
parameters: <left> <up> <text>
returncode: see "TEXTR"
CLRTEXTCS clears text written with TEXTCS
parameters: <left> <up> <text>
returncode: see "TEXTR"
The ARexx returncode values are 0 for OK, 5 for WARN and 10 for ERROR.
The valid data range for the commands LAPS, REFRACT, CYCLSEC, VIACYCL and
CORRECT is already described above.
For a correct sizing of the CLRTEXT~-commands you have to activate the same
text display font you used for the corresponding TEXT~-command which has to be
wiped out. In the same manner for clearing a text displayed with a shadowtext
command (CLRTEXT~S) the shadows must be set to their correct values.
For further details I refer to the example program "StopWatch.rexx", which
comes along with this package.
The abortion of NEXTTOTAL, NEXTLAP or NEXTSINGLE with "Abort RexxCmd" returns
an error level 10 in RC. If the "OPTIONS RESULTS" command is not active when
commands expect a return value (~TOTAL, ~LAP, ~SINGLE, SCREENADDRESS), an error
level 10 is returned.
IMPLEMENTATION
Most of the code is written in M2Amiga Modula 2 V3.1d (really antique version)
by AMSoft. I have implemented the interrupt routines in assembler using the
Aztec C 3.6a Assembler. Thanks to CygnusSoft for their excellent editor, which
helped me to keep the source together.
HISTORY
V 2.0 - First released version of the program, which already supports the
different Workbench fonts of AmigaDOS 2.0.
V 3.0 - Continuous time display in the program window.
- New timer REXX-Commands: PREVTOTAL, PREVLAP, PREVSINGLE, LOCKEXIT,
UNLOCKEXIT, LOCKTIMER, UNLOCKTIMER, BEEP.
- REXX-Commands GET... renamed to NEXT... !!
- Optional display-beep on all screens with the timer event. Activation
by the CLI-Option -b and the ToolType BEEP=ON.
- Correct 3D-Display also with the color palette of AmigaDOS 2.0.
- Assembly routines now coded and optimized with the Aztec Assembler, no
longer with the Data Becker Profimat-Assembler.
- REXX interface improved (unknown commands are sent back to the server
and don't cause Guru Meditations any longer..).
- Display Screen for genlock interaction.
Features: - Up to 16-color screen. Number of bit-planes and colors
definable by the user.
- Variable screen dimensions. Overscan supported.
- Free font selection. Color fonts in combination with the
"ColorText" program from the Calligrapher software
package possible.
- Position of actual, lap- and total time not fixed.
- Text- and graphics output via Rexx-commands (TIMEPOS,
TIMECOLOR, TIMEFONT, TEXTFONT, BOXO, BOXT, ELLIPSE, DRAW,
FILL, TEXTR, TEXTL, TEXTC, CLRTEXTR, CLRTEXTL, CLRTEXTC,
SHADOW, TEXTRS, TEXTLS, TEXTCS, CLRTEXTRS, CLRTEXTLS,
CLRTEXTCS, LOGO, CLRLOGO). SCREENADDRESS makes screen
manipulations by external programs possible.
V 3.0S - Shareware version of StopWatch V3.0. The sometimes on the display
screen appearing "Danner Timing"-logo reminds you to order the full
version and pay your registration fee.
The package consists of:
StopWatch Version 3.0S of the executable file
StopWatch.doc the user manual
StopWatch.rexx a demo file for ARexx-interfacing
StopWatch.pic a snapshot of the StopWatch screen while running
StopWatch.rexx (for those who do not yet use ARexx)
COPYRIGHT
Copyright (c) 1991 by Christian Danner. All rights reserved.
The author is not responsible for any damage caused by the use of the program
"StopWatch".
The shareware versions 2.0 and 3.0S of this program may only be redistributed
on non-commercial base without changes together with their documentation files.
They must not be distributed on commercial base without my explicit written
permission. If you use these versions more frequently, especially in a
professional manner, I won't refuse a little fee.
Version 3.0, which is neither in the public domain, nor shareware, can be
obtained via my address for the amount of 50 US$ or 80 DM (only bills)
including airmail postage and registration. Already registered users only have
to send me 5 US$ or 10 DM for forwarding expenses to receive the latest
version. Because of the external generation of the system frequency in genlock
mode I can not guarantee a correct time measurement in combination with all
kinds of genlock interfaces. So please check your hardware with one of the
shareware versions of this program before ordering.
For further improvements please let me know of all the bugs you find and all
the options you miss. Every attempt will be made to solve your problems within
a reasonable amount of time.
My address: Christian Danner
Rißkopfstraße 10
8106 Oberau
Germany
Phone: 08824/8122